package iscript.coreFramework.data 
{
	import iscript.coreFramework.data.datatable.DataTable;
	import iscript.coreFramework.data.datatable.DataTableError;
	public class DataSet 
	{
		public function DataSet(){}
		
		/*—————————DataTable————————————————————————————————————————————————————————————————————————————————————*/
		static private var _queueDataTable:Vector.<DataTable> = new Vector.<DataTable>();		
		static public function getTable(name:String):DataTable{
			for each( var item:DataTable in  datatableProvider){
				if(name==item.name) return item;
			}	
			return null;
		}
		
		static public function  addDataTable(datasource:DataTable):void{
			if(IsExistTable(datasource.name)) throw new Error("TableName:["+ datasource.name +"] "+ DataTableError.ExistDataTable);	
			_queueDataTable.push(datasource);
		}
		
		static public function  removeDataTable(datasource:DataTable):void{
			var index:int = _queueDataTable.indexOf(datasource);
			if (index != -1)
			_queueDataTable.splice(index, 1);
		}
		
		static public function clearDataTable():void {
			   _queueDataTable = new Vector.<DataTable>();			  
			}
		
		
		static public function IsExistTable(tableName:String):Boolean{
			for each( var item:DataTable in  datatableProvider){
				if(tableName==item.name) return true;
			}				
		    return false;
		}
		 
		static public function get datatableProvider():Vector.<DataTable> {
			return _queueDataTable; 
		}
         
		 
		/*—————————DataTree————————————————————————————————————————————————————————————————————————————————————*/
		static private var _queueDataTree:Vector.<DataTable> = new Vector.<DataTable>();		
	}

}